def object_to_dict(obj):
    '''
    将一个物体转化为dict
    '''
    if obj is None: return {}
    return {k : v for (k, v) in obj.__dict__.items() if k != "_state"}


def queryset_to_list_dict(queryset):
    '''
    将一个queryset转化为list(dict)
    '''
    obj_list = []
    for obj in queryset:
        obj_list.append(object_to_dict(obj))
    return obj_list
